//
//  ViewController.m
//  Test
//
//  Created by jansh on 16/1/12.
//  Copyright © 2016年 jansh. All rights reserved.
//

#import "ViewController.h"
#import "GHKeyBoardView.h"
#import <CommonCrypto/CommonDigest.h>
#import "LineView.h"
#import "GHAlertView.h"
#import "UpdateAlertView.h"
#import "NSString+DES.h"
#import "SingleTest.h"
#import "Son.h"
#import "NewViewController.h"
#import "TestViewController.h"
#import <ToolsFramework/ToolsFramework.h>
#import "Box.h"
#import "SomeOverException.h"
#import "SomethingException.h"
#import "GetImageSize.h"
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
#import "MuatbleAttributedView.h"

#define imagePath [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"ToolsBundle.bundle/Contents/Resources/"]
#define LocalImagePath(imageName) [imagePath stringByAppendingPathComponent:imageName]

#define Angle(a) (a)*M_PI/180
#define sAngle 6    //每秒旋转多少度：sAngle*N秒*M_PI/180

int GlobalInt = 0;
int (^globalInt)(void) = ^{return GlobalInt;};

static NSString *rotateAnimationKey = @"rotateAnimation";

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>
{
    UIImageView *imageView;
    CAAnimation *rotationAnimation;
    CFTimeInterval pausedTime;
    CALayer *layer;

}
@property (nonatomic, strong) UITextField *textFOne;
@property (nonatomic, copy) UITextView *textFTwo;
@property (nonatomic, copy) UITextField *textFThree;

@property (strong, nonatomic) NSArray *bookArray1;
@property (copy, nonatomic) NSArray *bookArray2;
@property (weak, nonatomic) IBOutlet UITableView *testTableView;

@property (retain,nonatomic) NSString *rStr;
@property (copy, nonatomic)   NSString *cStr;

@property (nonatomic, strong) NSMutableString *sMString;
@property (nonatomic, strong) NSMutableString *cMString;

@property (nonatomic) NSInteger dayTime;
@property (nonatomic) NSInteger hourTime;
@property (nonatomic) NSInteger minuteTime;
@property (nonatomic) NSInteger miaoTime;

@property (nonatomic, strong) GHAlertView *alertView;

@property (nonatomic,strong)CALayer *pointLayer;

@property (nonatomic, strong) CAEmitterLayer *emitterLayer;

@end

float rotationAnimationDuration = 1.0;
float scaleAnimationDuration = 3.0;

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
//    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"GHKeyBoardView" owner:self options:nil];
//    UIView *tmpCustomView = [nib objectAtIndex:0];
//    [self.view addSubview:tmpCustomView];
    
//    self.textFOne = [[UITextField alloc] initWithFrame:CGRectMake(0, 20, 200, 30)];
//    self.textFOne.backgroundColor = [UIColor brownColor];
//    [self.view addSubview:_textFOne];
//    
//    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
//    btn.frame = CGRectMake(230, 20, 80, 30);
//    btn.backgroundColor = [UIColor yellowColor];
//    [btn addTarget:self action:@selector(btnAction) forControlEvents:(UIControlEventTouchUpInside)];
//    [self.view addSubview:btn];
//    
//    
//    
//    _textFTwo = [[UITextView alloc] initWithFrame:CGRectMake(0, 60, 300, 300)];
//   _textFTwo.backgroundColor = [UIColor lightGrayColor];
//    [self.view addSubview:_textFTwo];
//    
//    _textFThree = [[UITextField alloc] initWithFrame:CGRectMake(0, 370, 300, 30)];
//_textFThree.backgroundColor = [UIColor magentaColor];
//    [self.view addSubview:_textFThree];
    
#pragma mark - 关于数组的 copy 和 strong 的测试
//    NSMutableArray *books = [@[@"book1"] mutableCopy];
//    self.bookArray1 = books;
//    self.bookArray2 = books;
//    [books addObject:@"book2"];
//    NSLog(@"bookArray1:%@",self.bookArray1);
//    NSLog(@"bookArray2:%@",self.bookArray2);
#pragma mark - 关于 NSString 的 copy 和 strong 的测试
//    NSString *mStr = [NSString stringWithFormat:@"abc"];
//    mStr = [mStr stringByAppendingString:@"de"];
//    self.rStr   = mStr;
//    self.cStr     = mStr;
//    NSLog(@"mStr:%p,%p,%@",  mStr,&mStr,mStr);
//    NSLog(@"retainStr:%p,%p, %@", _rStr, &_rStr, _rStr);
//    NSLog(@"copyStr:%p,%p, %@",   _cStr, &_cStr, _cStr);
//    NSLog(@"retainStr:%@",  _rStr);
//    NSLog(@"copyStr:%@",    _cStr);
//    
//    NSMutableString *Str = [NSMutableString stringWithFormat:@"abc"];
//    self.rStr = Str;
//    self.cStr = Str;
//    NSLog(@"mStr:%p,%p,%@",  Str,&Str,Str);
//    NSLog(@"retainStr:%p,%p, %@", _rStr, &_rStr, _rStr);
//    NSLog(@"copyStr:%p,%p, %@",   _cStr, &_cStr, _cStr);
//    [Str appendString:@"de"];
//    NSLog(@"retainStr:%@",  _rStr);
//    NSLog(@"copyStr:%@",    _cStr);
//    
//    self.sMString = [NSMutableString stringWithFormat:@"asd"];
//    self.cMString = [NSMutableString stringWithFormat:@"cde"];
//    
//    [self addStringWithString:self.sMString];
//    [self addStringWithString:_cMString];
//    NSLog(@"self.sMString = %@", self.sMString);
//    NSLog(@"self.cMString = %@", self.cMString);
    
    
//    __strong NSString *string1 = @"string1";
//    __weak NSString *string2 = string1;
//    string1 = nil;
//    NSLog(@"string2 = %@",string2);
//    NSLog(@"%@:%@", string1, [string1 class]);
    
//    NSString *string1 = @"string 1";
//    NSString *string2 = @"string 2";
//    NSString *string3 = [NSString stringWithFormat:@"string 3"];
//    NSString *string4 = @"string 4";
//    NSString *string5 = [[NSMutableString alloc] initWithString:@"string 5"];
//    NSLog(@"%@:%@",string1,[string1 class]);
//    NSLog(@"%@:%@",string2,[string2 class]);
//    NSLog(@"%@:%@",string3,[string3 class]);
//    NSLog(@"%@:%@",string4,[string4 class]);
//    NSLog(@"%@:%@",string5,[string5 class]);
    
#pragma mark - NSDateComponents
//    NSCalendar *calendar = [NSCalendar currentCalendar];
////    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:@"2016-01-31 00:00"];
//    NSUInteger unitFlags = NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay |NSCalendarUnitHour |NSCalendarUnitMinute;
//    NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:[NSDate dateWithTimeIntervalSinceNow:0]];
//    NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]];
//    
//    NSLog(@"cmp1.date.day = %ld", (long)cmp1.day);
//    NSLog(@"cmp1.date.month = %ld", (long)cmp1.month);
//    NSLog(@"cmp1.date.hour = %ld", (long)cmp1.hour);
//    NSLog(@"cmp1.date.minute = %ld", (long)cmp1.minute);
//    NSLog(@"cmp1.date.second = %ld", (long)cmp1.second);
//    
//    NSLog(@"cmp2.date.day = %ld", (long)cmp2.day);
//    NSLog(@"cmp2.date.month = %ld", (long)cmp2.month);
//    NSLog(@"cmp2.date.hour = %ld", (long)cmp2.hour);
//    NSLog(@"cmp2.date.minute = %ld", (long)cmp2.minute);
//    NSLog(@"cmp2.date.second = %ld", (long)cmp2.second);
//    
//    // 2.2.格式化日期
//    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//    if ([cmp1 day] == [cmp2 day]) { // 今天
//        formatter.dateFormat = @"今天 HH:mm:ss";
//    } else if ([cmp1 year] == [cmp2 year]) { // 今年
//        formatter.dateFormat = @"MM-dd HH:mm";
//    } else {
//        formatter.dateFormat = @"yyyy-MM-dd HH:mm";
//    }
//    NSString *time = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]];
//    NSLog(@"time = %@", time);
#pragma mark - 创建文件夹
//    NSArray *array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
//    NSLog(@"array = %ld", (unsigned long)array.count);
//    NSString *diskCachePath = [[array objectAtIndex:0] stringByAppendingPathComponent:@"ImageCache"];
//   
//    if (![[NSFileManager defaultManager] fileExistsAtPath:diskCachePath]) {
//        [[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath withIntermediateDirectories:NO attributes:nil error:nil];
//    }
//     NSLog(@"diskCachePath = %@", diskCachePath);
#pragma mark - 根据图片的地址随机为图片生成一个名字
//    const char *str = [@"http://img.hb.aicdn.com/66f828dfa80f71fe3db62adc11362aecc1995f0f1e7c3-9YHspI_fw658" UTF8String];
//    unsigned char r[CC_MD5_DIGEST_LENGTH];
//    CC_MD5(str, (CC_LONG)strlen(str), r);
//    NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]];
//    NSLog(@"filename = %@", filename);
    
#pragma mark - 利用当前时间与固定的结束时间做一个计时器
//    NSString *dateString = @"2016-01-31 00:00";
//    NSString *tmpStr = [self dateIntervalSinceNow:dateString];
//    NSLog(@"tmpStr = %@", tmpStr);
//    NSArray *array = [tmpStr componentsSeparatedByString:@":"];
//    self.dayTime = [array[0] integerValue];
//    self.hourTime = [array[1] integerValue];
//    self.minuteTime = [array[2] integerValue];
//    self.miaoTime = [array[3] integerValue];
//    
////    self.dayTime = 0;
//    self.hourTime = 1;
//    self.minuteTime = 1;
//    self.miaoTime = 7;
//    
//    UILabel *dayLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 100, 30)];
//    dayLabel.backgroundColor = [UIColor redColor];
//    dayLabel.tag = 400;
//    dayLabel.text = [NSString stringWithFormat:@"%ld", (long)_dayTime];
//    [self.view addSubview:dayLabel];
//    
//    UILabel *hourLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 20, 100, 30)];
//    hourLabel.backgroundColor = [UIColor greenColor];
//    hourLabel.tag = 300;
//    hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
//    [self.view addSubview:hourLabel];
//    
//    UILabel *minuteLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 100, 30)];
//    minuteLabel.backgroundColor = [UIColor blueColor];
//    minuteLabel.tag = 200;
//    minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
//    [self.view addSubview:minuteLabel];
//    
//    UILabel *miaoLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 60, 100, 30)];
//    miaoLabel.backgroundColor = [UIColor yellowColor];
//    miaoLabel.tag = 100;
//    miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
//    [self.view addSubview:miaoLabel];
//    
//    NSTimer *tmpTime = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(changeTime:) userInfo:nil repeats:YES];
//    [tmpTime fire];
#pragma mark - 绘图
//    LineView *line = [[LineView alloc] initWithFrame:CGRectMake(10, 20, 300, 300)];
//    [self.view addSubview:line];
    
//    [self addSubViews];
    
#pragma mark - 弹窗
    /**
    /// 如果加载的是 xib 的时候的调用方法
    //获得nib视图数组
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"GHAlertView" owner:self options:nil];
    //得到第一个UIView
    UIView *tmpCustomView = [nib objectAtIndex:0];
    //获得屏幕的Frame
//    CGRect tmpFrame = [[UIScreen mainScreen] bounds];
    //设置自定义视图的中点为屏幕的中点
    [tmpCustomView setCenter:CGPointMake([UIScreen mainScreen].bounds.size.width / 2, [UIScreen mainScreen].bounds.size.height / 2)];
    //添加视图
    [self.view addSubview:tmpCustomView];
     */
    
//    self.alertView = [GHAlertView  alertViewWithGHAlertView:@"提示" andWithMessage:@"网络异常" cancelButtonWithTitle:@"确认" otherButtonTitles:nil];
//    [self.view addSubview:_alertView];
    
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.frame = CGRectMake(100, 100, 100, 100);
//    button.backgroundColor = [UIColor redColor];
//    [button addTarget:self action:@selector(buttonActionOne:) forControlEvents:(UIControlEventTouchUpInside)];
    
//    [self.view addSubview:button];
#pragma mark - 判断手机号是否合法
//    [self isMobileNumber:@"13716557413"];
#pragma mark - 根据 label内容以及宽度,得到固定高度
//    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 64, 100, 30)];
//    label.numberOfLines = 0;
//    label.lineBreakMode = NSLineBreakByWordWrapping;
//    label.backgroundColor = [UIColor redColor];
//    label.text = @"生活如人饮水,\n冷暖自知,\n啦啦啦啦啦啦啦啦啦啦啦阿拉啦啦啦啦啦啦啦阿拉啦啦啦";
//    label.frame = [self getFrameWithWidth:100 AndWithString:label.text];
//    [self.view addSubview:label];
//    
//    NSLog(@"[UIFont systemFontSize] = %f", [UIFont labelFontSize]);
#pragma mark - block
//        GlobalInt += 1;
//        NSLog(@"globalInt = %d", GlobalInt);
//        [self setUpdata];
//    
//       __block int x = 123;
//        void (^getXAndY)(int) = ^(int y){
//            x = x+x;
//            NSLog(@"x = %d", x);
//            NSLog(@"y = %d", y);
//        };
//        getXAndY(456);
    
#pragma mark - 测试
//        UITableView *tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) style:(UITableViewStylePlain)];
//        tableV.backgroundColor = [UIColor redColor];
//        tableV.dataSource = self;
//        tableV.delegate = self;
//        [self.view addSubview:tableV];
#pragma mark - 单例测试
//        SingleTest *singleOne = [SingleTest sharedWithTest];
//        NSLog(@"singleOne = %@", singleOne);
//        SingleTest *singleTwo = [SingleTest sharedWithTest];
//        NSLog(@"singleTwo = %@", singleTwo);
//        SingleTest *singleThree = [[SingleTest alloc] init];
//        NSLog(@"singleThree = %@", singleThree);
//        SingleTest *singleFour = [SingleTest sharedWithTest];
//        NSLog(@"singleFour = %@", singleFour);
//    
//        Son *son = [[Son alloc] init];
//        NSLog(@"%@", son);
    
#pragma mark - 判断手机号是否合法
//        [self isMobileNumber:@"13716557413"];
//    
//        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"网络异常!" preferredStyle:(UIAlertControllerStyleAlert)];
//        [self presentViewController:alertVC animated:YES completion:nil];
    
#pragma mark - 从手写界面跳转到 xib 界面
//        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//        button.frame = CGRectMake(100, 100, 100, 50);
//        [button setBackgroundColor:[UIColor redColor]];
//        [button addTarget:self action:@selector(buttonAction) forControlEvents:(UIControlEventTouchUpInside)];
//        [self.view addSubview:button];
#pragma mark - 示例1
//        self.view.backgroundColor = [UIColor redColor];
//        CGMutablePathRef path = CGPathCreateMutable();
//        //将路径的起点定位到（50  120）
//        CGPathMoveToPoint(path,NULL,50.0,120.0);
//        //下面5行添加5条直线的路径到path中
//        CGPathAddLineToPoint(path,
//                             NULL, 60, 130);
//        CGPathAddLineToPoint(path,
//                             NULL, 70, 140);
//        CGPathAddLineToPoint(path,
//                             NULL, 80, 150);
//        CGPathAddLineToPoint(path,
//                             NULL, 90, 160);
//        CGPathAddLineToPoint(path,
//                             NULL, 100, 170);
//        //下面四行添加四条曲线路径到path
//        CGPathAddCurveToPoint(path,NULL,50.0,275.0,150.0,275.0,70.0,120.0);
//        CGPathAddCurveToPoint(path,NULL,150.0,275.0,250.0,275.0,90.0,120.0);
//        CGPathAddCurveToPoint(path,NULL,250.0,275.0,350.0,275.0,110.0,120.0);
//        CGPathAddCurveToPoint(path,NULL,350.0,275.0,450.0,275.0,130.0,120.0);
//        //以“position”为关键字
//    //    创建 实例
//        CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
//        //设置path属性
//        [animation setPath:path];
//        [animation setDuration:3.0];
//        //这句代码
//    //    表示 是否动画回到原位
//        [animation setAutoreverses:YES];
//        CFRelease(path);
//        [self.view.layer addAnimation:animation forKey:NULL];
#pragma mark - 示例2
//        CGPoint p1=CGPointMake(120, 50);
//        CGPoint p2=CGPointMake(80, 170);
//        CGPoint p3=CGPointMake(30, 100);
//        CGPoint p4=CGPointMake(100, 190);
//        CGPoint p5=CGPointMake(200, 10);
//        NSArray *values=[NSArray arrayWithObjects:[NSValue valueWithCGPoint:p1],[NSValue valueWithCGPoint:p2],[NSValue valueWithCGPoint:p3],[NSValue valueWithCGPoint:p4],[NSValue valueWithCGPoint:p5], nil];
//        CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
//        [animation setValues:values];
//        [animation setDuration:3.0];
//        [animation setAutoreverses:YES];
//        [self.view.layer addAnimation:animation forKey:NULL];
#pragma mark - 小球
//    UIView *subView = [[UIView alloc] initWithFrame:CGRectMake(100, 200, 50, 50)];
//    subView.layer.cornerRadius = 25;
//    subView.layer.masksToBounds = YES;
//    subView.backgroundColor = [UIColor redColor];
//    [self.view addSubview:subView];
//    
//    CGMutablePathRef path = CGPathCreateMutable();
//    CGPathMoveToPoint(path, &CGAffineTransformIdentity, 100, 200);
//    CGPathCloseSubpath(path);
//    
//    CGPathAddRelativeArc(path, &CGAffineTransformIdentity, 100, 110, 10, 10, 10);
//    CGPathAddQuadCurveToPoint(path, &CGAffineTransformIdentity, 100, 100, [UIScreen mainScreen].bounds.size.width/2-50, 300);
//    CGPathAddArc(path, &CGAffineTransformIdentity, 100, 100, 100, 50, 0, true);
//    CGPathAddArcToPoint(path, &CGAffineTransformIdentity, 100, 100, 200, 200, 10);
//    CGPathAddCurveToPoint(path, &CGAffineTransformIdentity, 100, 100, 300, 300, 200, 200);
//    CGPathAddRoundedRect(path, &CGAffineTransformIdentity, CGRectMake(0, 0, 100, 100), 50, 50);
//    CGPathCreateWithEllipseInRect(CGRectMake(100, 100, 100, 100), &CGAffineTransformIdentity);
//    
//    CAKeyframeAnimation *keyAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
//    [keyAnimation setPath:path];
//    [keyAnimation setAutoreverses:YES];
//    [keyAnimation setDuration:3.0];
//    [subView.layer addAnimation:keyAnimation forKey:@"position"];
    
#pragma mark - 点击事件
//        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//        button.frame = CGRectMake(100, 100, 100, 100);
//        [button setBackgroundColor:[UIColor redColor]];
//        [button addTarget:self action:@selector(buttonActionTouch:) forControlEvents:(UIControlEventTouchUpInside)];
//        [self.view addSubview:button];
//    
//        UIImageView *imageV_01 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 100, 100, 100)];
//        NSString *tmpString = [[NSBundle mainBundle] pathForResource:@"TestBundle" ofType:@".bundle"];
//        NSString *pathString = [tmpString stringByAppendingPathComponent:@"input"];
//        NSLog(@"tmpString = %@", pathString);
//        imageV_01.backgroundColor = [UIColor redColor];
//        imageV_01.image = [UIImage imageNamed:pathString];
//        [self.view addSubview:imageV_01];
//    
//        TestLog *test = [[TestLog alloc] init];
//        [test TestLog];
//    
////        NSString *imagePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"ToolsBundle.bundle/Contents/Resources/"];
//        NSString *tmpString_01 = [imagePath stringByAppendingPathComponent:@"delSelect@2x"];
//        UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 100, 100, 100)];
//        imageV.backgroundColor = [UIColor redColor];
//        imageV.image = [UIImage imageWithContentsOfFile:LocalImagePath(@"delSelect@2x")];
//        [self.view addSubview:imageV];
//    
//        TestViewController *testVC = [[TestViewController alloc] init];
//        testVC.view.backgroundColor = [UIColor yellowColor];
//        [self addChildViewController:testVC];
//        [self.view addSubview:testVC.view];

#pragma mark - 异常处理
//    Box *box = [[Box alloc]init];
//    for (int i = 0; i < 11; i++) {
//        @try {
//            [box pushIn];
//        }
//        @catch (SomethingException *exception) {
//            NSLog(@"%@ %@", [exception name], [exception reason]);
//        }
//        @catch (SomeOverException *exception) {
//            NSLog(@"%@", [exception name]);
//        }
//        @finally {
//            [box printNumber];
//        }
//    }
//    
//    @try {
//        [box setNumber:-10];
//    }
//    @catch (NSException *exception) {
//        NSLog(@"-=-=-=-=-=-%@",[exception name]);
//    }
//    @finally {
//        [box printNumber];
//    }
#pragma mark - 获取图片的大小
//    CGSize imageSize = [GetImageSize getImageSizeWithURL:[NSURL URLWithString:@"http://img.hb.aicdn.com/1c4e7678712fd3f7e8e6e7f21957bd0f21de568da759-mv6vsb_sq320"]];
//    NSLog(@"imageSize.width = %f",imageSize.width);
//    NSLog(@"imageSize.height = %f",imageSize.height);
    
#pragma mark - 使用safari对webview进行调试
//    http://www.saitjr.com/ios/ios-user-safari-debug-webview.html 该链接地址是使用 safair 对 webview 进行调试的教程地址
//    UIWebView *webV = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//    [webV loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]];
//    [self.view addSubview:webV];
#pragma mark - 组动画

//    UIView *orangeView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
//    orangeView.tag = 10010;
//    orangeView.backgroundColor = [UIColor orangeColor];
//    [self.view addSubview:orangeView];
//    
//    UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];
//    blackView.tag = 10011;
//    blackView.backgroundColor = [UIColor blackColor];
//    [self.view addSubview:blackView];
//    
//    [self orangeViewRotation];
//    [self blackViewScale];
    
#pragma mark - 当程序进入后的时候停止动画,返回前台的时候从停止动画的地方开始动画
//    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
//    lable.tag = 10010;
//    lable.text = @"label RotationAnimation Test";
//    lable.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2);
//    [self.view addSubview:lable];
//    
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height-30, [UIScreen mainScreen].bounds.size.width, 30);
//    button.backgroundColor = [UIColor brownColor];
//    [button addTarget:self action:@selector(startAnimation) forControlEvents:(UIControlEventTouchUpInside)
//    ];
//    [self.view addSubview:button];
//
//    [self setUpNotification];

#pragma mark - 对于 coreText的使用
//    MuatbleAttributedView *attributeView = [[MuatbleAttributedView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 500)];
//    attributeView.backgroundColor =[UIColor brownColor];
//    [self.view addSubview:attributeView];
    
#pragma mark - 时钟动画,以及touch 动画
//    //初始化CAlayer
//    layer = [CALayer layer];
//    layer.frame = CGRectMake(100, 100, 100, 100);
//    //设置图层拐角
//    layer.cornerRadius = 100/2;
//    layer.backgroundColor =[UIColor brownColor].CGColor;
//    //添加到父图层
//    [self.view.layer addSublayer:layer];
//    NSLog(@"%@",self.pointLayer);
//    _pointLayer.anchorPoint =CGPointMake(0, 0.5);
//    //放置一张图片
//    /*
//     图层上 要的是颜色（CGColorRef）  图片(CGImageRef)的 数据,而非UI
//     */
//    _pointLayer.contents =(id)[UIImage imageNamed:@"fox"].CGImage;
//    self.pointLayer.anchorPoint = CGPointMake(0.5, 0.9);
//    [self star];
//    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(star) userInfo:nil repeats:YES];

#pragma mark 粒子发送器
//    //初始化粒子发送器
//    self.emitterLayer.frame = CGRectMake(0, 300, 100,400);
//    //    设置粒子发送器 每秒钟发送的数量
//    self.emitterLayer.birthRate = 1;
//    //设置粒子的中心点
//    self.emitterLayer.position = CGPointMake(0, [UIScreen mainScreen].bounds.size.height/2);
//    //    设置粒子发送器的样式
//    self.emitterLayer.renderMode = kCAEmitterLayerBackToFront;
//    //设置粒子的中心店
//    self.emitterLayer.emitterPosition =self.view.center;
//    
//    //初始化粒子
//    CAEmitterCell *cell = [CAEmitterCell emitterCell];
//    cell.contents = (id)[UIImage imageNamed:@"fox"].CGImage;
//    //粒子的出生量
//    cell.birthRate = 10;
//    //粒子的存活时间，默认是0，单位是秒
//    cell.lifetime = 10;
//    cell.lifetimeRange =11;
//    //粒子发送的速度,默认是0
//    cell.velocity = 100;
//    cell.velocityRange= 10;
//    //设置粒子发送的 方向
//    cell.emissionLongitude = 30*M_PI/180;
//    cell.emissionLatitude = M_PI/180;
//    //设置粒子散发的范围 弧度
//    cell.emissionRange = 180*M_PI/180;
//    //设置粒子的加速度
//    cell.yAcceleration = -100;
//    // 把粒子的cell 放到粒子发送器上
//    self.emitterLayer.emitterCells = @[cell];

    
//    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.douban.com/j/app/radio/channels"]];
//    NSURLSessionConfiguration *config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
//    NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
//    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//        NSDictionary *tmpDic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:&error];
//        NSArray *array =[tmpDic valueForKey:@"channels"];
//        for (NSDictionary *dic in array) {
//            NSString *name = [dic valueForKey:@"name"];
//            NSLog(@"name = %@", name);
//            NSNumber *num = [dic valueForKey:@"channel_id"];
//            NSLog(@"channel_id = %d", num.intValue);
//        }
//    }];
//    [dataTask resume];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
//    if (cell == nil) {
//        cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:@"cell"];
//    }
    return cell;
}

-(CAEmitterLayer *)emitterLayer{
    if (_emitterLayer) {
        return _emitterLayer;
    }
    _emitterLayer =[CAEmitterLayer layer];
    [self.view.layer addSublayer:_emitterLayer];
    return _emitterLayer;
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    //获得点击触摸的点
    layer.position =[[touches anyObject] locationInView:self.view];
    CGFloat width =CGRectGetWidth(layer.bounds)!=100?100:50;
    //通过获得的点 改变尺寸
    layer.bounds =CGRectMake(0, 0, width, width);
    //改变颜色
    CGColorRef color = [UIColor brownColor].CGColor != layer.backgroundColor ?
    [UIColor brownColor].CGColor:
    [UIColor colorWithRed:0.863
                    green:0.634
                     blue:0.490
                    alpha:1.000].CGColor;
    layer.backgroundColor = color;
    //改变半径
    layer.cornerRadius =width!=100?0:width/2;
    //改变透明度
    layer.opacity = 0.3;
    
    
    //设置锚点,最大值是1，最小值是0
    _pointLayer.transform = CATransform3DMakeRotation(/*弧度*/Angle(60),0 , 0, 1);
    
    
    
}
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    layer.opacity = 1.0;
    //还原
    _pointLayer.transform = CATransform3DIdentity;
}

//利用懒加载 创建一个layer
-(CALayer *)pointLayer{
    if (_pointLayer) {
        return _pointLayer;
    }
    _pointLayer = [CALayer layer];
    _pointLayer.bounds =CGRectMake(0, 0, 18, 220);
    //设置中心点
    _pointLayer.position =self.view.center;
    _pointLayer.backgroundColor =
    [UIColor colorWithRed:1.000
                    green:0.392
                     blue:0.929
                    alpha:1.000].CGColor;
    [self.view.layer addSublayer:_pointLayer];
    return _pointLayer;
}
-(void)star{
    //NSCalendar 日历；可以获得年月日 时分秒,都是NSCalendar上的组件
    //    NSDateComponents
    //获得当前日历
    NSCalendar *calender =[NSCalendar currentCalendar];
    NSDateComponents *componest =[calender components:
                                  NSCalendarUnitHour|
                                  NSCalendarUnitMinute|
                                  NSCalendarUnitSecond fromDate:[NSDate date]];
    float s = componest.second * sAngle;
    _pointLayer.transform = CATransform3DMakeRotation(/*弧度*/Angle(s),0 , 0, 1);
}


- (void)setUpNotification
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForegroundNotification) name:UIApplicationWillEnterForegroundNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackgroundActionNotification) name:UIApplicationDidEnterBackgroundNotification object:nil];
}

- (void)applicationWillEnterForegroundNotification
{
    UILabel *label = [self.view viewWithTag:10010];
    if (rotationAnimation) {
        [label.layer addAnimation:rotationAnimation forKey:rotateAnimationKey];
    }
    rotationAnimation = nil;
}

- (void)applicationDidEnterBackgroundActionNotification
{
    UILabel *label = [self.view viewWithTag:10010];
    rotationAnimation = [label.layer animationForKey:rotateAnimationKey];
}


- (void)pauseLayer {
    UILabel *label = [self.view viewWithTag:10010];
    pausedTime = [label.layer convertTime:CACurrentMediaTime() fromLayer:nil];
    label.layer.speed = 0.0;
    label.layer.timeOffset = pausedTime;
}

- (void)resumeLayer
{
    UILabel *label = [self.view viewWithTag:10010];
    label.layer.speed = 1.0;
    label.layer.timeOffset = 0.0;
    label.layer.beginTime = 0.0;
    CFTimeInterval timeSincePause = [label.layer convertTime:CACurrentMediaTime() fromLayer:nil]-pausedTime;
    label.layer.timeOffset = timeSincePause;
}

- (void)startAnimation {
    UILabel *label = [self.view viewWithTag:10010];
    CABasicAnimation *rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    rotateAnimation.repeatCount = INFINITY;
    rotateAnimation.duration = 1.0;
    rotateAnimation.fromValue = @(-M_PI*2);
    [label.layer addAnimation:rotateAnimation forKey:rotateAnimationKey];
}

- (void)blackViewScale
{
    UIView *blackView = [self.view viewWithTag:10011];
    CABasicAnimation *animationScale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animationScale.duration = scaleAnimationDuration;
    animationScale.fromValue = @1;
    animationScale.toValue = @0.5;
    // 因为在放大以后，要停留在放大的状态，等待橘色视图旋转，所以使用 fillMode 和 removedOnCompletion 两个属性来将动画停留在最终的状态
    animationScale.fillMode = kCAFillModeBackwards;
    animationScale.removedOnCompletion = NO;
    /**
     *  
     kCAFillModeBackwards // 使得图像可以回到原来的状态,下边与此实现效果是一样的
     kCAFillModeRemoved
     kCAFillModeForwards // 这个可以使得图像保持在其已经缩放到的状态不会回到原型,下边那个与此实现效果是一样的
     kCAFillModeBoth
     */
    CAAnimationGroup *groupAnimation = [CAAnimationGroup animation];
    // 完成一组动画到开始下一组动画之间的时间间隔
    groupAnimation.duration = scaleAnimationDuration + rotationAnimationDuration/2.0;
    groupAnimation.repeatCount = INFINITY;
    groupAnimation.autoreverses = YES;
    
    groupAnimation.animations = @[animationScale];
    
    [blackView.layer addAnimation:groupAnimation forKey:@"scaleAnimation"];
}

- (void)orangeViewRotation
{
    UIView *orangeView = [self.view viewWithTag:10010];
    CABasicAnimation *rotationAnimationBasic = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    rotationAnimationBasic.fromValue = @(-M_PI * 2);
    rotationAnimationBasic.duration = rotationAnimationDuration;
    
    CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
    animationGroup.beginTime = CACurrentMediaTime()+scaleAnimationDuration;
    animationGroup.duration = rotationAnimationDuration + scaleAnimationDuration*2.0;
    animationGroup.repeatCount = INFINITY;
    animationGroup.animations = @[rotationAnimationBasic];
    [orangeView.layer addAnimation:animationGroup forKey:@"rotationAnimation"];
}

- (void)buttonActionTouch:(UIButton *)sender
{
    //    UIVisualEffectView *visualView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:(UIBlurEffectStyleDark)]];
    //    visualView.frame = [[UIScreen mainScreen] bounds];
    //    visualView.tag = 10086;
    //    [self.view addSubview:visualView];
    GHAlertView *alertV = [[GHAlertView alloc] init];
    [self.view addSubview:alertV];
    
}

- (void)buttonAction
{
    NewViewController *newVC = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
    [self.navigationController pushViewController:newVC animated:YES];
}

- (void)setUpdata
{
    NSString *passString = [NSString encryptWithText:@"111111a"];
    NSString *newStr = [NSString stringWithFormat:@"{\"CouUserPW\""@":"@"\"%@\""@","@"\"CouUserID\""@":"@"\"%@\""@","@"\"MsgCd\""@":"@"\"CS.116.001.01\""@"}", passString, @"shgly"];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", @"http://192.168.23.36:8080/cs-ims/cs/app/"]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"POST"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:[newStr dataUsingEncoding:NSUTF8StringEncoding]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];
#pragma clang diagnostic pop
    [connection start];
}


- (void)isMobileNumber:(NSString *)mobileNum
{
#pragma mark - 第一种检测手机号是否合法的方法
    // 手机号码
    NSString *MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$";
    //    // 中国移动
    //    NSString *CM = @"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\\d)\\d{7}$";
    //    // 中国联通
    //    NSString *CU = @"^1(3[0-2]|5[256]|8[56])\\d{8}$";
    //    // 中国电信
    //    NSString *CT = @"^1((33|53|8[09])[0-9]|349)\\d{7}$";
    //    // 大陆地区固话及小灵通
    //    //    NSString * PHS = @"^0(10|2[0-5789]|\\d{3})\\d{7,8}$";
    //    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
    //    NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];
    //    NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];
    //    NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];
    //    if (([regextestmobile evaluateWithObject:mobileNum] == YES) || ([regextestcm evaluateWithObject:mobileNum] == YES) || ([regextestct evaluateWithObject:mobileNum] == YES) || ([regextestcu evaluateWithObject:mobileNum] == YES)) {
    //        return YES;
    //    } else {
    //        return NO;
    //    }
# pragma mark - 第二种检测手机号是否合法的方式
    NSError *error;
    NSRegularExpression *express = [NSRegularExpression regularExpressionWithPattern:MOBILE options:NSRegularExpressionCaseInsensitive error:&error];
    NSTextCheckingResult *result = [express firstMatchInString:mobileNum options:(NSMatchingReportProgress) range:NSMakeRange(0, mobileNum.length)];
    if (result) {
        NSLog(@"匹配成功");
    } else {
        NSLog(@"匹配失败");
    }
}

- (void)buttonActionOne:(UIButton *)sender
{
    self.alertView = [GHAlertView alertViewWithGHAlertView:@"提示" andWithMessage:@"出现错误" cancelButtonWithTitle:@"确认" otherButtonTitles:@"取消", nil];
    [self.view addSubview:_alertView];
}

- (void)buttonAction:(UIButton *)sender
{
    [self.alertView removeFromSuperview];
}

- (void)addSubViews
{
//    self.view.backgroundColor = [UIColor whiteColor];
//    CGMutablePathRef pathRef=CGPathCreateMutable();
//    CGPathAddRect(pathRef, &CGAffineTransformIdentity, CGRectMake(100, 100, 100, 100));
//    CGPathMoveToPoint(pathRef, NULL, 4, 4);
//    CGPathAddLineToPoint(pathRef, NULL, 4, 8);
//    CGPathAddLineToPoint(pathRef, NULL, 10, 4);
//    CGPathAddLineToPoint(pathRef, NULL, 4, 4);
//    CGPathCloseSubpath(pathRef);
//    
//    CGPoint point=CGPointMake(5,7);
//    CGPoint outPoint=CGPointMake(5,10);
//    
//    if (CGPathContainsPoint(pathRef, NULL, point, NO)) {
//        NSLog(@"point in path!");
//    }
//    
//    if (!CGPathContainsPoint(pathRef, NULL, outPoint, NO)) {
//        NSLog(@"outPoint out path!");
//    }
    
    imageView=[[UIImageView alloc] initWithFrame:CGRectMake(100, 210, 200, 200)];
    [self.view addSubview:imageView];
    
    imageView.layer.borderColor = [UIColor blueColor].CGColor;
    imageView.layer.borderWidth = 2;
    
    UIGraphicsBeginImageContext(imageView.frame.size);
    [imageView.image drawInRect:CGRectMake(0, 0, 200, imageView.frame.size.height)];
    // 控制线的形状
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
//    // 线的宽度
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10.0);
    CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);
    // 修改线的颜色
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.5, 0.5, 0.5, 1.0);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 2, 50);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 196, 50);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    imageView.image=UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    
}

// 根据文本内容以及 label 的固定宽度,获得高度
- (CGRect)getFrameWithWidth:(CGFloat)width AndWithString:(NSString *)tmpString
{
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:[UIFont labelFontSize]] forKey:NSFontAttributeName];
    // 宽度同 label 一样,高度要取到一个不可能的值
    CGRect tmpFrame = [tmpString boundingRectWithSize:CGSizeMake(width, 1000000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    CGRect newFrame = CGRectMake(10, 64, width, tmpFrame.size.height);
    return newFrame;
}

- (void)changeTime:(NSTimer *)tmpTime
{
    UILabel *miaoLabel = [self.view viewWithTag:100];
    UILabel *minuteLabel = [self.view viewWithTag:200];
    UILabel *hourLabel = [self.view viewWithTag:300];
    UILabel *dayLabel = [self.view viewWithTag:400];
    if (_miaoTime == 0 && _minuteTime == 0 && _hourTime == 0 && _dayTime == 0) {
        [tmpTime invalidate];
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
        dayLabel.text = [NSString stringWithFormat:@"%ld", (long)_dayTime];
    } else if (_miaoTime == 0 && _minuteTime != 0 && _hourTime == 0 && _dayTime == 0) {
        _miaoTime = 59;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        _minuteTime--;
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
    } else if (_miaoTime == 0 && _minuteTime == 0 && _hourTime != 0 && _dayTime == 0) {
        _miaoTime = 59;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        _minuteTime = 59;
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        _hourTime--;
        hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
    } else if (_miaoTime == 0 && _minuteTime == 0 && _hourTime == 0 && _dayTime != 0) {
        _miaoTime = 59;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        _minuteTime = 59;
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        _hourTime = 24;
        hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
        _dayTime--;
        dayLabel.text = [NSString stringWithFormat:@"%ld", (long)_dayTime];
    } else if (_miaoTime == 0 && _minuteTime != 0 && _hourTime != 0 && _dayTime != 0){
        _miaoTime = 59;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        _minuteTime --;
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        if (_minuteTime == 0) {
            _minuteTime = 59;
            minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
            _hourTime --;
            hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
            if (_hourTime == 0) {
                _hourTime = 24;
                hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
                _dayTime--;
                dayLabel.text = [NSString stringWithFormat:@"%ld", (long)_dayTime];
            }
        }
    } else if (_miaoTime != 0 && _minuteTime == 0 && _hourTime == 0 && _dayTime == 0) {
        _miaoTime--;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
        dayLabel.text = [NSString stringWithFormat:@"%ld", (long)_dayTime];
    } else if (_miaoTime != 0 && _minuteTime != 0 && _hourTime != 0 && _dayTime != 0) {
        _miaoTime--;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
        dayLabel.text = [NSString stringWithFormat:@"%ld", (long)_dayTime];
    } else if (_miaoTime != 0 && _minuteTime == 0 && _hourTime != 0 && _dayTime != 0) {
        _miaoTime --;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        _minuteTime = 59;
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        _hourTime--;
        hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
    } else if (_miaoTime != 0 && _minuteTime != 0 && _hourTime == 0 && _dayTime != 0) {
        _miaoTime --;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        _minuteTime --;
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        _hourTime = 24;
        hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
        _dayTime--;
        dayLabel.text = [NSString stringWithFormat:@"%ld", (long)_dayTime];
    } else if (_miaoTime != 0 && _minuteTime != 0 && _hourTime != 0 && _dayTime == 0) {
        _miaoTime --;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
    } else if (_miaoTime == 0 && _minuteTime != 0 && _hourTime != 0 && _dayTime == 0) {
        _miaoTime = 59;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
        _minuteTime--;
        minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
        if (_minuteTime == 0) {
            _minuteTime = 59;
            minuteLabel.text = [NSString stringWithFormat:@"%ld", (long)_minuteTime];
            _hourTime--;
            hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
            if (_hourTime == 0) {
                hourLabel.text = [NSString stringWithFormat:@"%ld", (long)_hourTime];
            }
        }
    } else if (_miaoTime != 0 && _minuteTime != 0 && _hourTime == 0 && _dayTime == 0) {
        _miaoTime--;
        miaoLabel.text = [NSString stringWithFormat:@"%ld", (long)_miaoTime];
    }
}

- (NSString *)dateIntervalSinceNow:(NSString *)dateString // 对声明方法的实现
{
    NSString *tmpString = @"";
    NSDateFormatter *forr = [[NSDateFormatter alloc] init];
    [forr setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSDate *strDate = [forr dateFromString:dateString];
    NSTimeInterval tmpInter = [strDate timeIntervalSinceDate:[NSDate dateWithTimeIntervalSinceNow:0]];
    NSLog(@"tmpInter = %f", tmpInter/86400);
    CGFloat day = tmpInter/86400;
    NSString *dayStr = [NSString stringWithFormat:@"%f", day];
    dayStr = [dayStr substringToIndex:dayStr.length - 7];
    NSLog(@"dayStr = %@", dayStr);
    CGFloat hour = (day - [dayStr doubleValue])*24;
    NSString *hourStr = [NSString stringWithFormat:@"%f", hour];
    hourStr = [hourStr substringToIndex:hourStr.length-7];
    NSLog(@"hourStr = %@", hourStr);
    CGFloat minute = (hour - [hourStr doubleValue])*60;
    NSString *minuteStr = [NSString stringWithFormat:@"%f", minute];
    minuteStr = [minuteStr substringToIndex:minuteStr.length - 7];
    NSLog(@"minuteStr = %@", minuteStr);
    CGFloat miao = (minute - [minuteStr doubleValue])*60;
    NSString *miaoStr = [NSString stringWithFormat:@"%f", miao];
    miaoStr = [miaoStr substringToIndex:miaoStr.length-7];
    NSLog(@"miao = %@", miaoStr);
    tmpString = [NSString stringWithFormat:@"%@:%@:%@:%@", dayStr,hourStr, minuteStr, miaoStr];
    return tmpString;
}

- (void)btnAction
{
    NSLog(@"slkfjs");
    NSLog(@"self.textFOne.text = %@", self.textFOne.text);
    [self showTextFieldText:self.textFOne AndWithTextView:self.textFTwo];
    
    [self showTextFieldText:self.textFThree AndWithTextView:self.textFTwo];
}


- (void)showTextFieldText:(UITextField *)textField AndWithTextView:(UITextView *)textView
{
//    NSLog(@"textField = %@", textField);
    textView.text = textField.text;
}

- (void)addStringWithString:(NSMutableString *)mString
{
    [mString appendString:@"123456"];
    [mString appendFormat:@"helllo"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
